/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.giangnd.btvn2;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 *
 * @author GIANG
 */
public class B10 {
    public static boolean ngto(int n){
        if(n<2)return false;
        for(int i=2;i<=Math.sqrt(n);i++)
        if(n%i==0) return false;
        return true;
    }
    public static void main(String[] args) throws FileNotFoundException, IOException {
        BufferedReader br = new BufferedReader(new FileReader("Data/B10.txt"));
        BufferedWriter bf= new BufferedWriter(new FileWriter("Data/B10OUT.txt"));
            String s = br.readLine();
            System.out.println("Input" + s);
            StringTokenizer s1 = new StringTokenizer(s);
            String a[] = new String[100];
            int k = 0;
            int b[]=new int[100];
            while (s1.hasMoreTokens()) {
                a[k] = s1.nextToken();
                b[k++]=0;
            }
            long m[]=new long[100];
            for(int i=0;i<k;i++){m[i]=Integer.parseInt(a[i]);if(m[k]<2)
                b[k]=1;}
            for(int i=0;i<k-1;i++){
                if(b[i]==0)
                for(int j=i+1;j<k;j++){
                    if(m[i]==m[j])b[j]=1;
                }
            }
            System.out.println("So nguyen to :");
            bf.write("So ngto :");
            bf.newLine();
            for(int i=0;i<k;i++)
                if(ngto((int) m[i]) && b[i]==0){
                System.out.print(m[i]+" ");
                bf.write(m[i]+" ");
                }
            bf.close();
    }
    }
    